A mobile device such as a cellular phone or a smart phone can now be equipped with a compass. The compass can calculate and provide its user with a direction, which may be a “heading” (typically given relative to the Earth's magnetic field), and/or an arrow pointing to true north. The direction information may be provided for the user's own navigation knowledge, for example, to tell him which way is north while he is walking or driving in unfamiliar surroundings. The direction information is also beneficial for use by a navigation or map application that may be running in the device.
A compass can obtain a measure of the magnetic field that is present in its immediate surrounding as a three-component (e.g., in x, y, and z directions) vector, using a 3-axis magnetic sensor called a magnetometer. The sensed field contains a contribution by the Earth's magnetic field, and a contribution by a local interference field. The latter is the magnetic field that is created by components in the local environment of the mobile device, and can include hard and soft iron components. Hard iron refers to magnetic materials that are difficult to magnetize, but once magnetized will retain the magnetism for long periods of time. Soft iron refers to metals that are easily magnetized, but lose their magnetic state once the magnetizing force is removed. These local magnetic effects may include contributions by any magnetic component that is near the sensor, such as a loudspeaker that is built into the device. The interference field may also have a contribution due to magnetic elements found in the external environment close to the device, such as when the user is driving an automobile, riding in a train or bus, or riding on a bicycle or motorcycle.
In order to account for these additional environmental magnetic fields, the magnetometer should be calibrated. Conventional magnetometer calibration procedures may require the user to maneuver the device in a defined pattern to generate data that can be used to calibrate the magnetometer. Such manual calibration procedures are required to be performed each time the magnetometer error exceeds a threshold value. Additionally, the user may have to repeat the calibration procedure if performed incorrectly or if the user originally performs the calibration procedure in a location that has significant sources of error (e.g., large amounts of metal nearby.)